home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / PInterfaces / WorldScript.p < prev   
Encoding:
Text File  |  1994-11-11  |  9.3 KB  |  360 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        WorldScript.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT WorldScript;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __WORLDSCRIPT__}
  27. {$SETC __WORLDSCRIPT__ := 1}
  28.  
  29. {$I+}
  30. {$SETC WorldScriptIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __TRAPS__}
  40. {$I Traps.p}
  41. {$ENDC}
  42.  
  43. {$IFC UNDEFINED __QUICKDRAWTEXT__}
  44. {$I QuickdrawText.p}
  45. {$ENDC}
  46. {    MixedMode.p                                                    }
  47.  
  48. {$PUSH}
  49. {$ALIGN MAC68K}
  50. {$LibExport+}
  51.  
  52. CONST
  53.     kVariableLengthArray        = 1;
  54.  
  55.     
  56. TYPE
  57.     WSIOffset = UInt16;
  58.  
  59.     WSIByteCount = UInt8;
  60.  
  61.     WSIByteIndex = UInt8;
  62.  
  63. { offset from start of sub-table to row in state table }
  64.     WSIStateOffset = UInt16;
  65.  
  66.     WSITableOffset = UInt32;
  67.  
  68.     WSISubtableOffset = UInt16;
  69.  
  70.     WSIGlyphcode = UInt16;
  71.  
  72.     WSITableIdentifiers = UInt32;
  73.  
  74.  
  75. CONST
  76.     kScriptSettingsTag            = 'info';
  77.     kMetamorphosisTag            = 'mort';
  78.     kGlyphExpansionTag            = 'g2g#';
  79.     kPropertiesTag                = 'prop';
  80.     kJustificationTag            = 'kash';
  81.     kCharToGlyphTag                = 'cmap';
  82.     kGlyphToCharTag                = 'pamc';
  83.     kFindScriptRunTag            = 'fstb';
  84.  
  85. {***             L O O K U P    T A B L E    T Y P E S        ***}
  86.     WSILookupSimpleArray        = 0;                            { a simple array indexed by glyph code }
  87.     WSILookupSegmentSingle        = 2;                            { segment mapping to single value }
  88.     WSILookupSegmentArray        = 4;                            { segment mapping to lookup array }
  89.     WSILookupSingleTable        = 6;                            { sorted list of glyph, value pairs }
  90.     WSILookupTrimmedArray        = 8;                            { a simple trimmed array indexed by glyph code }
  91.  
  92.     
  93. TYPE
  94.     WSILookupTableFormat = INTEGER;
  95.  
  96.     WSILookupValue = INTEGER;
  97.  
  98. { An offset from the beginning of the lookup table }
  99.     WSILookupOffset = INTEGER;
  100.  
  101. {    FORMAT SPECIFIC DEFINITIONS }
  102. {
  103.         lookupSimpleArray:
  104.         
  105.         This is a simple array which maps all glyphs in the font
  106.         to lookup values.
  107.     }
  108.     WSILookupArrayHeader = RECORD
  109.         lookupValues:            ARRAY [0..0] OF WSILookupValue;            { The array of values indexed by glyph code }
  110.     END;
  111. {
  112.         lookupTrimmedArray:
  113.         
  114.         This is a single trimmed array which maps a single range
  115.         of glyhs in the font to lookup values.
  116.     }
  117.     WSILookupTrimmedArrayHeader = RECORD
  118.         firstGlyph:                WSIGlyphcode;
  119.         limitGlyph:                WSIGlyphcode;
  120.         valueArray:                ARRAY [0..0] OF WSILookupValue;
  121.     END;
  122. { The format specific part of the subtable header }
  123.     WSILookupFormatSpecificHeader = RECORD
  124.         CASE INTEGER OF
  125.         0: (
  126.             lookupArray:                WSILookupArrayHeader;
  127.            );
  128.         1: (
  129.             trimmedArray:                WSILookupTrimmedArrayHeader;
  130.            );
  131.     END;
  132. { The overall subtable header }
  133.     WSILookupTableHeader = RECORD
  134.         format:                    WSILookupTableFormat;                    { table format }
  135.         fsHeader:                WSILookupFormatSpecificHeader;            { format specific header }
  136.     END;
  137. {***        G L Y P H    E X P A N S I O N    ***}
  138.  
  139. CONST
  140. { fixed 1.0 }
  141.     kCurrentGlyphExpansionVersion = $00010000;
  142.  
  143.     
  144. TYPE
  145.     GlyphExpansionFormats = INTEGER;
  146.  
  147.  
  148. CONST
  149.     GlyphExpansionLookupFormat    = 1;
  150.     GlyphExpansionContextualFormat = 2;
  151.  
  152.  
  153. TYPE
  154.     ExpandedGlyphCluster = PACKED RECORD
  155.         numGlyphs:                WSIByteCount;
  156.         bestGlyph:                WSIByteIndex;
  157.         glyphs:                    ARRAY [0..0] OF WSIGlyphcode;
  158.     END;
  159.     ExpandedGlyphOffset = RECORD
  160.         glyph:                    WSIGlyphcode;
  161.         offset:                    WSIOffset;                                { offset to ExpandedGlyphCluster }
  162.     END;
  163.     GlyphExpansionStateTable = RECORD
  164.         stateTableOffset:        WSISubtableOffset;
  165.         classTableOffset:        WSISubtableOffset;
  166.         actionTableOffset:        WSISubtableOffset;                        { state, class and actions tables follow here... }
  167.     END;
  168.     GlyphExpansionTable = RECORD
  169.         version:                Fixed;
  170.         format:                    INTEGER;
  171.         expansionNumer:            INTEGER;
  172.         expansionDenom:            INTEGER;                                { num/denom ratio for expansion <2> }
  173.         CASE INTEGER OF
  174.         0: (
  175.             stateTable:                    GlyphExpansionStateTable;
  176.            );
  177.         1: (
  178.             lookup:                        WSILookupTableHeader;                { expanded glyph clusters follow here... }
  179.            );
  180.     END;
  181. { Glyph-to-Character constants and types  }
  182.  
  183. CONST
  184.     kCurrentGlyphToCharVersion    = $00010100;
  185.  
  186.     
  187. TYPE
  188.     GlyphToCharLookupFormats = INTEGER;
  189.  
  190.  
  191. CONST
  192.     kGlyphToCharLookup8Format    = 1;
  193.     kGlyphToCharLookup16Format    = 2;
  194.     kGlyphToCharLookup32Format    = 3;
  195.  
  196.     
  197. TYPE
  198.     GlyphToCharFontIndex = UInt8;
  199.  
  200.     QDGlyphcode = UInt8;
  201.  
  202.     GlyphToCharActionTable = RECORD
  203.         fontNameOffset:            WSISubtableOffset;                        { offset relative to this table }
  204.         actions:                WSILookupTableHeader;                    { only support lookupSimpleArray format for now }
  205.     END;
  206.     GlyphToCharActionHeader = RECORD
  207.         numTables:                INTEGER;                                { 0..n }
  208.         offsets:                ARRAY [0..0] OF WSISubtableOffset;        { offsets from start of action table header }
  209.     END;
  210.     GlyphToCharHeader = RECORD
  211.         version:                Fixed;
  212.         actionOffset:            WSISubtableOffset;                        { offset to GlyphToCharActionHeader }
  213.         format:                    INTEGER;                                { size of font mask }
  214.         mappingTable:            WSILookupTableHeader;
  215.     END;
  216. { JUSTIFICATION TYPES
  217.     WorldScript supports justification of text using insertion. The justification
  218.     table specifies a insertion string to insert between 2 specified glyphs.
  219.     Each combination of inter-glyph boundary can be assigned a justification priority,
  220.     the higher the priority the more justification strings inserted at that position.
  221.     
  222.     The priorities for each inter-glyph boundary are specified by the justification table's
  223.     state table.
  224.     
  225.     Special handling is done for scripts which use spaces to justify, because the width of 
  226.     a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  227.     per inserting string is specified in the justification table.
  228.  
  229. }
  230.  
  231. CONST
  232. { 1.0 not supported }
  233.     kCurrentJustificationVersion = $0200;
  234.  
  235.     kJustificationStateTableFormat = 1;
  236.  
  237. { WSI's internal limitation <12> }
  238.     kMaxJustificationStringLength = 13;
  239.  
  240.     
  241. TYPE
  242.     WSIJustificationPriority = UInt8;
  243.  
  244.  
  245. CONST
  246.     WSIJustificationSetMarkMask    = $80;
  247.  
  248.  
  249. TYPE
  250.     WSIJustificationStateEntry = PACKED RECORD
  251.         markPriority:            WSIJustificationPriority;                { non-zero priorities means insertion }
  252.         priority:                WSIJustificationPriority;
  253.         newState:                WSIStateOffset;
  254.     END;
  255.     WSIJustificationClasses = INTEGER;
  256.  
  257.  
  258. CONST
  259.     wsiJustEndOfLineClass        = 0;
  260.     wsiJustEndOfRunClass        = 1;
  261.     wsiJustDeletedGlyphClass    = 2;
  262.     wsiJustUserDefinedClass        = 3;
  263.  
  264.     
  265. TYPE
  266.     WSIJustificationStates = INTEGER;
  267.  
  268.  
  269. CONST
  270.     wsiStartOfLineState            = 0;                            { pre-defined states }
  271.     wsiStartOfRunState            = 1;
  272.     wsiUserDefinedState            = 2;
  273.  
  274. { pre-multiplied: class# * sizeof(WSIJustificationStateEntry) }
  275.     
  276. TYPE
  277.     WSIJustificationClassOffset = UInt8;
  278.  
  279.     WSIJustificationStateTable = RECORD
  280.         maxPriorities:            INTEGER;
  281.         rowWidth:                INTEGER;                                { width of a state table row in bytes }
  282.         classTableOffset:        INTEGER;
  283.         stateTableOffset:        INTEGER;
  284.     END;
  285.     WSIJustificationHeader = RECORD
  286.         version:                INTEGER;
  287.         format:                    INTEGER;
  288.         scaling:                Point;                                    { numer/denom scaling of priority weights <7> }
  289.         spacesPerInsertion:        INTEGER;                                { # of $20 chars in justification insertion string <12> }
  290.         justStringOffset:        INTEGER;                                { offset to justification string }
  291.         stateTable:                WSIJustificationStateTable;                { long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows }
  292.     END;
  293. { Line Layout's Property table version <11> }
  294.  
  295. CONST
  296. { v1.0 }
  297.     currentPropsTableVersion    = $00010000;
  298.  
  299. { ??? is this right }
  300.     kCharToGlyphCurrentVersion    = 0100;
  301.  
  302. { pass as priorityWeight to JustifyWSILayout to use script's current just setting }
  303.     kScriptsDefaultJustWeight    = -1;
  304.  
  305.  
  306. TYPE
  307.     WSIGlyphInfoRec = RECORD
  308.         qdChar:                    SInt8;
  309.         rightToLeft:            SInt8;                                    { !0 means rightToLeft, 0 means leftToRight }
  310.         fontID:                    INTEGER;
  311.         originalOffset:            INTEGER;                                { or negative original offset if not in original text input }
  312.         unused:                    INTEGER;                                { long-align }
  313.     END;
  314.     WSIGlyphInfoRecPtr = ^WSIGlyphInfoRec;
  315.     WSIGlyphInfoHandle = ^WSIGlyphInfoRecPtr;
  316.  
  317.     WSILayoutHandle = Handle;
  318.  
  319.  
  320. FUNCTION NewWSILayout(layoutH: WSILayoutHandle; text: Ptr; txLength: INTEGER; lineDirection: INTEGER; flags: LONGINT; VAR err: OSErr): WSILayoutHandle;
  321.     {$IFC NOT GENERATINGCFM}
  322.     INLINE $2F3C, $8414, $0040, $A8B5;
  323.     {$ENDC}
  324. FUNCTION JustifyWSILayout(layoutH: WSILayoutHandle; slop: Fixed; priorityWeight: INTEGER; styleRunPosition: JustStyleCode; numer: Point; denom: Point; VAR err: OSErr): WSILayoutHandle;
  325.     {$IFC NOT GENERATINGCFM}
  326.     INLINE $2F3C, $8418, $0042, $A8B5;
  327.     {$ENDC}
  328. FUNCTION MeasureWSILayout(layoutH: WSILayoutHandle; numer: Point; denom: Point): Fixed;
  329.     {$IFC NOT GENERATINGCFM}
  330.     INLINE $2F3C, $840C, $0044, $A8B5;
  331.     {$ENDC}
  332. PROCEDURE DrawWSILayout(layoutH: WSILayoutHandle; numer: Point; denom: Point);
  333.     {$IFC NOT GENERATINGCFM}
  334.     INLINE $2F3C, $800C, $0046, $A8B5;
  335.     {$ENDC}
  336. { "low-level" routines }
  337. FUNCTION GetWSILayoutParts(layoutH: WSILayoutHandle; destH: WSIGlyphInfoHandle; VAR numGlyphs: INTEGER; VAR err: OSErr): WSIGlyphInfoHandle;
  338.     {$IFC NOT GENERATINGCFM}
  339.     INLINE $2F3C, $8410, $0048, $A8B5;
  340.     {$ENDC}
  341. PROCEDURE DrawWSIGlyphs(length: INTEGER; qdCodes: Ptr; numer: Point; denom: Point);
  342.     {$IFC NOT GENERATINGCFM}
  343.     INLINE $2F3C, $800E, $004A, $A8B5;
  344.     {$ENDC}
  345. FUNCTION xMeasureWSIGlyphs(VAR qdCodes: Ptr; length: INTEGER; numer: Point; denom: Point): Fixed;
  346.     {$IFC NOT GENERATINGCFM}
  347.     INLINE $2F3C, $840E, $004C, $A8B5;
  348.     {$ENDC}
  349.  
  350. {$ALIGN RESET}
  351. {$POP}
  352.  
  353. {$SETC UsingIncludes := WorldScriptIncludes}
  354.  
  355. {$ENDC} {__WORLDSCRIPT__}
  356.  
  357. {$IFC NOT UsingIncludes}
  358.  END.
  359. {$ENDC}
  360.